package com.app.controller;


import com.app.common.Result;
import com.app.model.CustomerServiceModel;
import com.app.service.CustomerServiceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/customerService")
public class CustomerServiceController {
    @Autowired
    private CustomerServiceService customerServiceService;


    /**
     * 新增客服
     * @param dto
     * @return
     */
    @PostMapping("/addAndUpdate")
    public Result addAndUpdate(@RequestBody CustomerServiceModel dto){
        return customerServiceService.addAndUpdate(dto);
    }

    /**
     * 删除客服信息（假删除）
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result delete(Integer id){
        return customerServiceService.delete(id);
    }

    /**
     * 更改客服状态
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/updateStatus")
    public Result updateStatus(Integer id,Integer status){
        return customerServiceService.updateStatus(id,status);
    }

//    /**
//     * 修改客服信息
//     * @param dto
//     * @return
//     */
//    @PutMapping("/updateCustomerServiceDetail")
//    public Result update(@RequestBody CustomerServiceModel dto){
//        return customerServiceService.updateCSM(dto);
//    }

    /**
     * 根据id查询客服详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public Result detail(Integer id){
        return customerServiceService.detail(id);
    }

    /**
     * 查询客服绑定的行家的信息
     * @param id
     * @return
     */
    @GetMapping("/businessList")
    public Result businessList(Integer id,Integer page, Integer limit, String keyword, String areaId){
        return customerServiceService.businessList(id,page,limit,keyword,areaId);
    }
    /**
     * 客服绑定新的商家们
     * @param businessIds
     * @param customerId
     * @param type 1解绑  2绑定
     * @return
     */
    @PutMapping("/bindUnbind")
    public Result updateCustomer(List<Integer> businessIds,Integer customerId,Integer type){
        return customerServiceService.updateBusinessIds(businessIds,customerId,type);
    }

    /**
     * moveFromAtoB
     * @param aid
     * @param bid
     * @param businessId
     * @return
     */
    @GetMapping("/moveFromAtoB")
    public Result moveFromAtoB( Integer aid,Integer bid,Integer businessId){
        return customerServiceService.moveFromAtoB(aid,bid,businessId);
    }

    /**
     *
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(defaultValue = "1") Integer pageNo,@RequestParam(defaultValue = "10") Integer pageSize,Integer areaId,String keyword){
        return customerServiceService.getlist(pageNo,pageSize,areaId,keyword);
    }

    /**
     * 获取列表
     *
     * @return {@link Result}
     */
    @GetMapping("/getList")
    public Result getList(){
        return customerServiceService.selectList();
    }
}
